Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add object actions - presigned URL, download and preview #1604

Conversation

@@ -91,6 +92,7 @@
"js-base64": "^2.1.9",
"js-yaml": "^3.13.1",
"lodash-es": "^4.17.21",
"luxon": "^3.3.0",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reason why we need this: https://stackoverflow.com/a/1214753

Copy link
Collaborator

@alfonsomthd alfonsomthd Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Luxon is a modern replacement for deprecated Moment.js

Comment on lines -24 to -50
const CreatedOnSkeleton: React.FC<{}> = () => (
<Skeleton width="25%" height="15%" />
);

const CreatedOn: React.FC<{ bucketName: string }> = ({ bucketName }) => {
const { t } = useCustomTranslation();

const { noobaaS3 } = React.useContext(NoobaaS3Context);
const { data, error, isLoading } = useSWR(LIST_BUCKET, () =>
noobaaS3.listBuckets()
);

const bucketCreatedOn =
!isLoading && !error
? data?.Buckets?.find((bucket) => bucket?.Name === bucketName)
?.CreationDate
: null;

return isLoading ? (
<CreatedOnSkeleton />
) : (
<h4 className="text-muted">
{t('Created on: ') + bucketCreatedOn?.toString()}
</h4>
);
};

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can not be determined that easily, decided to remove it instead...

Comment on lines 40 to 43
{
title: t('Copy Object URL'),
onClick: () => undefined,
},
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for this... we can not determine this...

@SanjalKatiyar SanjalKatiyar changed the title [WIP] Add object actions - presigned URL Add object actions - presigned URL Oct 2, 2024
@SanjalKatiyar SanjalKatiyar changed the title Add object actions - presigned URL [WIP] Add object actions - presigned URL, download and preview Oct 3, 2024
@SanjalKatiyar SanjalKatiyar force-pushed the actions_presigned_url branch 2 times, most recently from 9e945f5 to 2a2cda6 Compare October 3, 2024 06:36
@SanjalKatiyar SanjalKatiyar changed the title [WIP] Add object actions - presigned URL, download and preview Add object actions - presigned URL, download and preview Oct 3, 2024
) => Promise<string>;

export type DownloadAndPreviewState = {
isdownloading: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
isdownloading: boolean;
isDownloading: boolean;

// open the object URL in a new browser tab
window.open(objectURL, '_blank');
} catch (err) {
// eslint-disable-next-line no-console
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can consider to allow error console method in order to avoid adding eslint-disable comments...
If we go ahead this can be done in a cleanup PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense to me !!

export const numberInputOnChange =
(min: number, max: number, onChange: (value: number) => void) =>
(input: React.FormEvent<HTMLInputElement>): void => {
const inputValue = +(input.target as HTMLInputElement)?.value;
Copy link
Contributor

@GowthamShanmugam GowthamShanmugam Oct 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this min-max comparision? is this for the corner case of entering the value directly?
I am assuming NumberInput won't allow to increase or decrease values less than or greater than min max value

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will be used when u will type/enter the number directly into the input...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


return (
<FormGroup label={t('Expires after')} fieldId="expires-after">
<NumberInput
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is RequestSizeInput can be used here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, maybe we can utilise it with some refactoring... but will take it up in a followup PR...

<FormGroup label={t('Share link')} fieldId="share-link">
<div className="pf-v5-u-text-align-right text-muted">
<b>{t('Valid until: ')}</b>
{urlDetails.current.validUntil}{' '}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{urlDetails.current.validUntil}{' '}
{urlDetails.current.validUntil}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added by linter... AFAIR I didn't add this...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

@GowthamShanmugam
Copy link
Contributor

LGTM

@alfonsomthd
Copy link
Collaborator

/lgtm

Copy link
Contributor

openshift-ci bot commented Oct 4, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alfonsomthd, SanjalKatiyar

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [SanjalKatiyar,alfonsomthd]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit abb8239 into red-hat-storage:master Oct 4, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants